<link href="../core/resource/css/diy.css?v=32" rel="stylesheet">
<link href="../core/resource/css/pc.css?v=95" rel="stylesheet">
<style>
.jinyun-modal-dialog, .modal-dialog {
    min-width: 180px!important;
    position: absolute;
    left: 0;
    right: 0;
    top: 42%;
}
.container {width:1170px;}
</style>
<!--头部-->
<div ng-if="pagedata.item.type<=2" class="pc-header selected" style="min-height:60px" ng-if="pagedata.item.pctype<2">
	<div class="panel-layer" ng-repeat="head in pagedata.item.head_items" onmouseenter="$(this).children('.panel-edit').show();$(this).addClass('selected');" onmouseleave="$(this).children('.panel-edit').hide();$(this).removeClass('selected');">
		<div class="panel-edit" ng-class="{'edit-left':head.cloud_id==4}">
			<a ng-if="head.cloud_id==4" ng-click="pagedata.add(head.childs);" class="btn btn-default edit-a">添加组件</a>
			<a ng-if="head.cloud_id==4" ng-click="pagedata.edit_detail(head);" class="btn btn-default edit-a">容器样式</a>
			<a ng-if="head.cloud_id!=4" ng-click="pagedata.edit_detail(head);" class="btn btn-warning edit-a">组件内容</a>
			<a ng-if="head.cloud_id!=4" ng-click="pagedata.edit_style(head);" class="btn btn-warning edit-a">组件样式</a>
			<a ng-click="pagedata.item.head_items.splice($index,1);" class="btn btn-danger edit-a">删除</a>
		</div>
		<div class="panel-show" ng-include="pagedata.show_html(head.cloud_id,'head')" ></div>
	</div>
	<div class="panel-add" ng-if="!pagedata.item.head_items.length" ng-class="{'panel-header-edit':pagedata.pc_head.childs.length==0}">
		<button class="btn btn-default" ng-click="pagedata.add(pagedata.item.head_items,0);">添加头部组件</button>
	</div>
</div>
<div ng-if="pagedata.item.type==3" class="pc-footer selected" style="min-height:60px;background:#dff8f3">
	<div class="bold" style="text-align:center;color:#999">
		<div style="font-size:30px;">PC顶部内容</div>
		<div style="font-size:12px;">当前页面不能编辑</div>
	</div>
</div>
<!--主页面-->
<div ng-if="pagedata.item.type<2" ng-class="{'pc-body selected':1,'container':pagedata.item.is_narrow==1}" style="min-height:460px">
   <div ng-class="{'panel-layer ov_selected':1, 'selected':pagedata.pc_selectid==$index}" ng-click="pagedata.pc_selectid=$index" ng-repeat="item in pagedata.item.pc_items" onmouseenter="$(this).children('.panel-edit').show();" onmouseleave="$(this).children('.panel-edit').hide();">
<!--第一层，遍历页面的组件-->
		<div class="panel-edit" ng-class="{'edit-left':item.cloud_id==4}">
			<a ng-if="item.cloud_id==4" ng-click="pagedata.add(item.childs);" class="btn btn-default edit-a">添加组件</a>
			<a ng-if="item.cloud_id==4" ng-click="pagedata.edit_detail(item);" class="btn btn-default edit-a">容器样式</a>
			<a ng-if="item.cloud_id!=4" ng-click="pagedata.edit_detail(item);" class="btn btn-warning edit-a">组件内容</a>
			<a ng-if="item.cloud_id!=4" ng-click="pagedata.edit_style(item);" class="btn btn-warning edit-a">组件样式</a>
			<a ng-click="pagedata.item.pc_items.splice($index,1);" class="btn btn-danger edit-a">删除</a>
		</div>
		<div class="panel-show" ng-include="pagedata.show_html(item.cloud_id,'item')" ></div>
	</div>
	<div class="panel-add" ng-class="{'panel-main-edit':pagedata.current_page.childs.length==0}">
		<button class="btn btn-default" ng-click="pagedata.add(pagedata.item.pc_items,1);">添加内容组件</button>
	</div>
</div>
<div ng-if="pagedata.item.type>=2" ng-class="{'pc-body selected':1,'container':pagedata.item.is_narrow==1}" style="min-height:460px;background:#dff8f3">
	<div class="bold" style="margin:180px;text-align:center;color:#999">
		<div style="font-size:50px;">PC页面主内容</div>
		<div style="font-size:12px;">当前页面不能编辑</div>
	</div>
</div>
<!--底部-->
<div ng-if="pagedata.item.type<2 || pagedata.item.type==3" class="pc-footer selected" style="min-height:120px" ng-if="pagedata.item.pctype<2">
	<div class="panel-layer" ng-repeat="foot in pagedata.item.foot_items" onmouseenter="$(this).children('.panel-edit').show();$(this).addClass('selected');" onmouseleave="$(this).children('.panel-edit').hide();$(this).removeClass('selected');">
		<div class="panel-edit" ng-class="{'edit-left':foot.cloud_id==4}">
			<a ng-if="foot.cloud_id==4" ng-click="pagedata.add(foot.childs);" class="btn btn-default edit-a">添加组件</a>
			<a ng-if="foot.cloud_id==4" ng-click="pagedata.edit_detail(foot);" class="btn btn-default edit-a">容器样式</a>
			<a ng-if="foot.cloud_id!=4" ng-click="pagedata.edit_detail(foot);" class="btn btn-warning edit-a">组件内容</a>
			<a ng-if="foot.cloud_id!=4" ng-click="pagedata.edit_style(foot);" class="btn btn-warning edit-a">组件样式</a>
			<a ng-click="pagedata.item.foot_items.splice($index,1);" class="btn btn-danger edit-a">删除</a>
		</div>
		<div class="panel-show" ng-include="pagedata.show_html(foot.cloud_id,'foot')" ></div>
	</div>
	<div class="panel-add" ng-if="!pagedata.item.foot_items.length" ng-class="{'panel-footer-edit':pagedata.pc_foot.childs.length==0}">
		<button class="btn btn-default" ng-click="pagedata.add(pagedata.item.foot_items,2);">添加底部组件</button>
	</div>
</div>
<div ng-if="pagedata.item.type==2" class="pc-footer selected" style="min-height:120px;background:#dff8f3">
	<div class="bold" style="margin:40px;text-align:center;color:#999">
		<div style="font-size:50px;">PC底部内容</div>
		<div style="font-size:12px;">当前页面不能编辑</div>
	</div>
</div>
<!--底部保存-->
<div class="fe-save">
    <div class="fe-save-main" style="float:right;width:auto;margin-right:80px">
		<div class="fe-save-submit2" style="line-height:40px;width:150px">
				窄边？
				<span ng-show="pagedata.item.is_narrow==1" class="switch switchOn" ng-click="pagedata.item.is_narrow=0"></span>
				<span ng-show="pagedata.item.is_narrow!=1" class="switch" ng-click="pagedata.item.is_narrow=1"></span>
		</div>
		<div class="fe-save-submit2" ng-click="post(pagedata.item,'post','look=1')">保存并预览</div>
        <div class="fe-save-submit save-submit" ng-click="post(pagedata.item,'post')">保存</div>
        <div class="fe-save-fold" onclick="fold()"></div>
        <div class="fe-save-gotop" onclick="$(document.body).animate({scrollTop:0},500)"><i class="fa fa-angle-up"></i><br>返回顶部</div>
    </div>
</div>
<div ng-show="pagedata.show_edit">
	<div class="pc-modal-dialog pc-dialog">
		<div class="modal-content pc-modal diy-editor" style="top: 51px;min-height: 368px;left: 136px;">
			<div id="dragModal" class="modal-body form-horizontal " style="padding:0px;" ng-include="pagedata.edit_url" onload="start()"></div>
			<div class="modal-footer">
				<a class="btn btn-default" ng-click="pagedata.show_edit=false;">确定</a>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="../core/resource/components/ueditor/third-party/zeroclipboard/ZeroClipboard.js"></script>
<script type="text/javascript" src="../core/resource/components/ueditor/ueditor.config.js?v=20191210"></script>
<script type="text/javascript" src="../core/resource/components/ueditor/ueditor.all.min.js?v=20191212"></script>
<script type="text/javascript" src="../core/resource/components/ueditor/ueditor.parse.js?v=20191208"></script>
<script type="text/javascript" src="../core/resource/components/ueditor/lang/zh-cn/zh-cn.js?v=20190608"></script>
<script>
	function fold(){
        width= $(".fe-save").width();
        left = $(".fe-save").css("left");
        left = left.replace("px","");
        if(left>=0){
            $(".fe-save").animate({left:0-width+40+"px"},1000);
            $(".fe-save-fold").addClass("fe-save-fold2");
        }else{
            $(".fe-save").animate({left:"0px"},1000);
            $(".fe-save-fold").removeClass("fe-save-fold2");
        }
    }
	//设置参数全部调用modal页面进行设置。以加快开发进度
	//组件或容器详情设置
	window.scope.pagedata.show_html=function(id,item){
		var url='../api.php?this=manage&token='+window.scope.pagedata.token+'&plugin=core&action=website.pc_design&op=html&id='+id+'&item='+item;
		//console.log(url);
		return url;
	}
	window.scope.pagedata.edit_detail=function(item){
		window.scope.pagedata.current_edit=item.params;
		window.scope.pagedata.edit_url=window.scope.tomedia(window.scope.pagedata.blocks[item.cloud_id].edithtml,true);
		window.scope.pagedata.show_edit=true;
	}
	//组件或容器风格样式设置
	window.scope.pagedata.edit_style=function(item){
		
		window.scope.pagedata.current_edit=item.style;
		//console.log(window.scope.pagedata.current_edit);
		window.scope.pagedata.edit_url=window.scope.sys_html('website/pc_design_style',true);
		
		window.scope.pagedata.show_edit=true;
		//window.scope.$apply();
	}
	//系统链接选择
	window.scope.pagedata.link=function(value,field,query){	
		if(scope.pagedata.item.system){
			//选择管理端链接
			console.log('选择管理端页面');
			scope.modal_func(value,field,'tools.link_system');
		}else{
			console.log('选择用户端页面');
			//默认都选择action模式
			if(query){
				query='action';
			}
			var webid=scope.pagedata.item.id
			window.scope.choose_link(value,field,query,'core/website.mobile_web/link',webid);
		}
	}
	window.scope.pagedata.add=function(item,type){
		window.scope.pagedata.html_type=type;
		if(type==1){
			window.scope.pagedata.current_edit={'op':'r'};
		}else if(type==0){
			window.scope.pagedata.current_edit={'op':'h'};
		}else if(type==2){
			window.scope.pagedata.current_edit={'op':'f'};
		}
		item=item?item:[];
		window.scope.pagedata.current_add_to=item; 
		console.log(item)
		window.scope.pagedata.edit_url=window.scope.sys_html('website/pc_design_add',true);;
		window.scope.pagedata.show_edit=true;
		
	}
	window.scope.pagedata.add_post=function(item){
		console.log(item)
		var temp={'type':item.type,'cloud_id':item.cloud_id,'style':{},'params':angular.copy(item.default),'childs':[]};
		window.scope.pagedata.current_add_to.push(temp);
	}
</script>
